<?php
	require(__META_CONTROLS_GEN__ . '/AddressMetaControlGen.class.php');

	/**
	 * This is a MetaControl customizable subclass, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality of the
	 * Address class.  This code-generated class extends from
	 * the generated MetaControl class, which contains all the basic elements to help a QPanel or QForm
	 * display an HTML form that can manipulate a single Address object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a AddressMetaControl
	 * class.
	 *
	 * This file is intended to be modified.  Subsequent code regenerations will NOT modify
	 * or overwrite this file.
	 * 
	 * @package My QCubed Application
	 * @subpackage MetaControls
	 */
	class AddressMetaControl extends AddressMetaControlGen {
		// Initialize fields with default values from database definition
/*		
		public function __construct($objParentObject, Address $objAddress) {
			parent::__construct($objParentObject,$objAddress);
			if ( !$this->blnEditMode ){
				$this->objAddress->Initialize();
			}
		}
*/               protected $dttTime;
                 public function SaveAddress() {
                            parent::SaveAddress();

                        try {
                                //$this->objAddress->Save();
                                $this->dttTime = new QDateTime();
                                $this->dttTime->setDate (date("Y"), date("m"), date("d"));
                                $this->dttTime->setTime (date("H"), date("i"), date("s"));

                                $CurrentUser = $_SESSION['User']['Id'];

                                if ($this->blnEditMode){
                                    //Update
                                    $this->objAddress->UpdateBy   = $CurrentUser;
                                    $this->objAddress->UpdateDate = $this->dttTime;
                                }
                                else{
                                    //New
                                    $this->objAddress->CreateBy   = $CurrentUser;
                                    $this->objAddress->CreateDate = $this->dttTime;
                                }
                                $this->objAddress->Save();

                            } catch (QCallerException $objExc) {
                                    $objExc->IncrementOffset();
                                    throw $objExc;
                            }
                 }
	}
?>